#include "type.h"

#ifndef ITG3200_H_
#define ITG3200_H_

#define ITG3200_I2C_ADDRESS 0xD0

/* ITG-3200 sensitivity is 14.375 LSB/(degrees/sec). */
#define GYROSCOPE_GAIN (1 / 14.375)

#define WHO_AM_I_REG    0x00
#define SMPLRT_DIV_REG  0x15
#define DLPF_FS_REG     0x16
#define INT_CFG_REG     0x17
#define INT_STATUS      0x1A
#define TEMP_OUT_H_REG  0x1B
#define TEMP_OUT_L_REG  0x1C
#define GYRO_XOUT_H_REG 0x1D
#define GYRO_XOUT_L_REG 0x1E
#define GYRO_YOUT_H_REG 0x1F
#define GYRO_YOUT_L_REG 0x20
#define GYRO_ZOUT_H_REG 0x21
#define GYRO_ZOUT_L_REG 0x22
#define PWR_MGM_REG     0x3E

#define LPFBW_256HZ 0x00
#define LPFBW_188HZ 0x01
#define LPFBW_98HZ  0x02
#define LPFBW_42HZ  0x03
#define LPFBW_20HZ  0x04
#define LPFBW_10HZ  0x05
#define LPFBW_5HZ   0x06
#define LPBFW_STD   (0x03 << 3)

#define SAMPLE_RATE_200   0x04

void itg3200_init(void);
uint32_t itg3200_read_id(uint8_t *id);
uint32_t itg3200_read_reg(uint8_t reg, uint8_t *data);
uint32_t itg3200_write_reg(uint8_t reg, uint8_t *data);
uint32_t itg3200_read_xyz(int16_t *readings);

#endif /* ITG3200_H_ */
